package com.pretty.test.controller.pets.volunteer;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pretty.test.controller.pets.volunteer.dto.VolunteerPageDTO;
import com.pretty.test.controller.pets.volunteer.vo.VolunteerPageVO;
import com.pretty.test.entity.PetsVolunteer;
import com.pretty.test.service.IPetsVolunteerService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 志愿者控制器
 * @author dujianyu
 * @since 2021-04-06
 */
@RestController
@AllArgsConstructor
@RequestMapping("/volunteer")
public class PetsVolunteerController {

    private IPetsVolunteerService service;

    /**
     * 自定义分页
     * @param page
     * @param dto
     */
    @GetMapping("/page")
    public R<IPage<VolunteerPageVO>> page(Page<VolunteerPageVO> page, VolunteerPageDTO dto){
        return R.ok(service.selectVolunteerPage(page,dto));
    }

    /**
     * 新增或修改
     * @param petsVolunteer
     */
    @PostMapping("/submit")
    public  R<Boolean> submit(@RequestBody PetsVolunteer petsVolunteer){
        return R.ok(service.saveOrUpdate(petsVolunteer));
    }

    /**
     * 逻辑删除
     * @param id
     */
    @PostMapping("/delete")
    public R<Boolean> delete(String id){
        return R.ok(service.removeById(id));
    }

}
